package com.braveman.im.ui.activity.mine;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.braveman.im.R;
import com.braveman.im.bean.FriendshipListBean;
import com.braveman.im.factory.FragmentFactoryForIM;
import com.braveman.im.ui.activity.SearchResultActivity;
import com.braveman.im.utils.UtilsStyle;
import com.ht.baselibs.core.EventCode;
import com.ht.baselibs.ui.base.BaseActivity;
import com.ht.baselibs.ui.widget.TitleBarView;
import com.ht.baselibs.utils.ActivityUtils;
import com.ht.baselibs.utils.UIUtils;
import com.vondear.rxtools.RxBarTool;

import java.io.Serializable;
import java.util.List;


public class GetMineFriendsAndGroupActivity extends BaseActivity {


    private int listType;

    @Override
    protected void initTitleBar() {
        String title = "";
        switch (listType) {
            case 1:
                title = "我的群";
                mTitleBarView.addActions(new TitleBarView.Action(R.mipmap.personal_card_detail_title_icon_add) {
                    @Override
                    public void performAction(View view) {
                        Bundle bundle = new Bundle();
                        bundle.putInt("mRefreshType", 1);
                        ActivityUtils.startActivity(GetMineFriendsAndGroupActivity.this, SearchResultActivity.class, bundle);
                    }
                });
                break;
            case 2:
                title = "我的单位";
                mTitleBarView.addActions(new TitleBarView.Action(R.mipmap.personal_card_detail_title_icon_add) {
                    @Override
                    public void performAction(View view) {
                        Bundle bundle = new Bundle();
                        bundle.putInt("mRefreshType", 0);
                        ActivityUtils.startActivity(GetMineFriendsAndGroupActivity.this, SearchResultActivity.class, bundle);
                    }
                });
                break;
            case 3:
                title = "我的好友";
                break;
            case 4:
                title = "选择名片";
                break;
        }
        mTitleBarView.setTitleText(title).setLeftBtnIcon(R.mipmap.back_black).setOnLeftBtnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ActivityUtils.finishActivity(GetMineFriendsAndGroupActivity.this);
            }
        });
    }

    @Override
    protected boolean isStaticPage() {
        return true;
    }

    @Override
    protected void initIntentData(Intent callIntent) {
        listType = callIntent.getIntExtra("listType", -1);
    }

    @Override
    protected int initContentView() {
        UtilsStyle.setStatusBarMode(this, true);
        RxBarTool.FlymeSetStatusBarLightMode(getWindow(), true);
        RxBarTool.MIUISetStatusBarLightMode(getWindow(), true);
        return R.layout.activity_mine_friends;
    }

    @Override
    protected void initChildView() {
        switch (listType) {
            case 1://群
                switchFragment(FragmentFactoryForIM.getTabFragment(FragmentFactoryForIM.FRAGMENT_IM_TAB1), R.id.content_container);
                break;
            case 2://单位
//                switchFragment(FragmentFactoryForIM.getTabFragment(FragmentFactoryForIM.FRAGMENT_IM_TAB1), R.id.content_container);
                break;
            case 3://单
                switchFragment(FragmentFactoryForIM.getTabFragment(FragmentFactoryForIM.FRAGMENT_IM_TAB2), R.id.content_container);
                //拓展
                break;
            case 4://名片
                switchFragment(FragmentFactoryForIM.getTabFragment(FragmentFactoryForIM.FRAGMENT_IM_TAB4), R.id.content_container);
                //拓展
                break;
            default:
                UIUtils.showToast("请重试");
        }
    }

    @Override
    protected void initChildData() {

    }

    @Override
    protected void setChildViewListener() {

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        FragmentFactoryForIM.mHomeIMTabMap.clear();
    }

    @Override
    protected boolean hasEvent() {
        return true;
    }

    @Override
    protected void onEvent(int eventCode, Object data) {
        switch (eventCode) {
            case EventCode.EVENT_SET_RESULT:
                Intent intent = (Intent) data;
                setResult(RESULT_OK, intent);
                ActivityUtils.finishActivity(this);
                break;
        }
    }
}
